<?php

require_once 'include/language_manager.inc.php';
Language_Manager::getInstance();

$meta["title"] = L::meta_faq_title;
$meta["description"] = L::meta_faq_description;
$meta["keywords"] = L::meta_faq_keywords;

require "include/template_manager.inc.php";
$myTemplate = new Template_Manager("faq", null, true, 5, $meta);

$sql = "SELECT * FROM faqs ORDER BY id";
$prefix = "/";
if (getLanguage() == 'en') {
    $prefix = "/en/";
}
if ($data = DB_Manager::getInstance()->query($sql)) {

    while ($row = $data->fetch_array(MYSQLI_ASSOC)) {
        $domanda = "";
        $risposta = "";
        if (getLanguage() == 'it') {
            $domanda = $row['domanda'];
            $risposta = $row['risposta'];
        } else {
            $domanda = $row['domanda_en'];
            $risposta = $row['risposta_en'];
        }
        $myTemplate->setBodyContentString("domanda", $domanda);
        $myTemplate->setBodyContentString("risposta", $risposta);
    }
} else{
    $myTemplate->setBodyDBError(DB_Manager::getInstance());
}
$myTemplate->setCanonicalUrl($prefix . "faq/");

$myTemplate->setBodyContentString("nav_message", L::nav_message);
$myTemplate->setBodyContentString("nav_home", L::nav_home);
$myTemplate->setBodyContentString("nav_page", L::messages_faq_nav_page);